package com.zcn.io.web.controller;

import com.zcn.io.common.entity.AnswerTemplate;
import com.zcn.io.common.pojo.CommonResult;
import com.zcn.io.web.service.AnswerTemplateService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @desc:
 * @author: 202438 邱建伟
 * @date: 2024/10/5 19:00
 * @Copyright (c) 2024, All Rights Reserved.
 */
@RestController
@RequestMapping("/answerTemplate")
@RequiredArgsConstructor
public class AnswerTemplateController {

    private final AnswerTemplateService answerTemplateService;

    @GetMapping("/listAll")
    public CommonResult<List<AnswerTemplate>> listAll() {
        return CommonResult.success(answerTemplateService.listAll());
    }

    @PostMapping("/save")
    public CommonResult<String> save(@RequestBody AnswerTemplate answerTemplate) {
        answerTemplateService.save(answerTemplate);
        return CommonResult.success("保存成功");
    }

    @PostMapping("/updateById")
    public CommonResult<String> updateById(@RequestBody AnswerTemplate answerTemplate) {
        answerTemplateService.updateById(answerTemplate);
        return CommonResult.success("更新成功");
    }

    @DeleteMapping("/deleteById")
    public CommonResult<String> deleteById(String id) {
        answerTemplateService.deleteById(id);
        return CommonResult.success("删除成功");
    }

    @GetMapping("/getLatestOne")
    public CommonResult<AnswerTemplate> getLatestOne() {
        return CommonResult.success(answerTemplateService.getLatestOne());
    }


}
